package de.smarthome.szenario;

import android.app.ActionBar;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;
import de.smarthome.R;
import de.smarthome.adapter.InfoScreenAdapter;
import de.smarthome.database.DatabaseHandler;

public class DetailScreen extends ListActivity {

	DatabaseHandler dbHandler;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_detail_screen);
		dbHandler = new DatabaseHandler(this);
		Bundle extras = getIntent().getExtras();
		ActionBar bar = getActionBar();
		bar.setDisplayHomeAsUpEnabled(true);

		getListView().setAdapter(new InfoScreenAdapter(this,dbHandler.getScenarioInfo(extras.getString("name"))));
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    switch (item.getItemId()) {
	        case android.R.id.home:
	            Intent intent = new Intent(this, ListScenario.class);
	            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
	            startActivity(intent);
	            return true;
	        default:
	            return super.onOptionsItemSelected(item);
	    }
	}
	
	
}
